package com.tailyou.androidlearning202400.act

import android.graphics.Color
import android.os.Bundle
import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.View
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.tailyou.androidlearning202400.R

class LoginActivity_JD : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        this.enableEdgeToEdge()
        setContentView(R.layout.activity_login_jd)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v: View, insets: WindowInsetsCompat ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        val tvAgree = findViewById<TextView>(R.id.tvAgree)
        // 设置部分文字显示不同颜色
        val ss =
            SpannableString("我已阅读并同意《京东隐私政策》《京东用户服务协议》未注册的手机号将自动创建京东账号")
        ss.setSpan(
            ForegroundColorSpan(Color.parseColor("#0E8BAF")),
            7,
            15,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        ss.setSpan(
            ForegroundColorSpan(Color.parseColor("#0E8BAF")),
            15,
            25,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        tvAgree.text = ss
    }
}